insert overwrite table jms_dws.dws_order_day_cnt_dt partition(dt)
    select 
         dt                                    as input_date 
        ,order_source_code                     as order_source_code
        ,max(order_source_name)                as order_source_name
        ,pick_network_code                     as pick_network_code
        ,max(pick_network_name)                as pick_network_name
        ,max(pick_franchisee_code)             as pick_franchisee_code
        ,max(pick_franchisee_name)             as pick_franchisee_name
        ,max(pick_agent_code)                  as pick_agent_code
        ,max(pick_agent_name)                  as pick_agent_name
        ,sender_province_id                    as sender_province_id
        ,sender_province_name                  as sender_province_name
        ,sender_city_id                        as sender_city_id
        ,sender_city_name                      as sender_city_name
        ,sender_area_id                        as sender_area_id
        ,sender_area_name                      as sender_area_name
        ,sum(delete_cnt)                       as delete_cnt 
        ,sum(cancel_cnt)                       as cancel_cnt 
        ,sum(normal_cnt)                       as normal_cnt
        ,sum(all_cnt)                          as all_cnt
        ,dt
from jms_dws.dws_order_hour_cnt_dt
where dt = '{{ execution_date | cst_ds }}' 
group by 
        dt           
       ,order_source_code
       ,pick_network_code
       ,sender_province_id
       ,sender_province_name
       ,sender_city_id
       ,sender_city_name
       ,sender_area_id
       ,sender_area_name
   distribute by 1 ;